<template>
  <div class="app-container">
    <!-- 对话框(添加 / 修改) -->
    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
      <el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
                    <el-form-item label="机构ID" prop="orgid">
                      <el-input v-model="formData.orgid" placeholder="请输入机构ID" />
                    </el-form-item>
                    <el-form-item label="机构名称" prop="orgname">
                      <el-input v-model="formData.orgname" placeholder="请输入机构名称" />
                    </el-form-item>
                    <el-form-item label="证券代码" prop="seccode">
                      <el-input v-model="formData.seccode" placeholder="请输入证券代码" />
                    </el-form-item>
                    <el-form-item label="证券简称" prop="secname">
                      <el-input v-model="formData.secname" placeholder="请输入证券简称" />
                    </el-form-item>
                    <el-form-item label="英文名称" prop="f001v">
                      <el-input v-model="formData.f001v" placeholder="请输入英文名称" />
                    </el-form-item>
                    <el-form-item label="英文简称" prop="f002v">
                      <el-input v-model="formData.f002v" placeholder="请输入英文简称" />
                    </el-form-item>
                    <el-form-item label="法人代表" prop="f003v">
                      <el-input v-model="formData.f003v" placeholder="请输入法人代表" />
                    </el-form-item>
                    <el-form-item label="注册地址" prop="f004v">
                      <el-input v-model="formData.f004v" placeholder="请输入注册地址" />
                    </el-form-item>
                    <el-form-item label="办公地址" prop="f005v">
                      <el-input v-model="formData.f005v" placeholder="请输入办公地址" />
                    </el-form-item>
                    <el-form-item label="邮政编码" prop="f006v">
                      <el-input v-model="formData.f006v" placeholder="请输入邮政编码" />
                    </el-form-item>
                    <el-form-item label="注册资金" prop="f007n">
                      <el-input v-model="formData.f007n" placeholder="请输入注册资金" />
                    </el-form-item>
                    <el-form-item label="货币编码" prop="f008v">
                      <el-input v-model="formData.f008v" placeholder="请输入货币编码" />
                    </el-form-item>
                    <el-form-item label="货币名称" prop="f009v">
                      <el-input v-model="formData.f009v" placeholder="请输入货币名称" />
                    </el-form-item>
                    <el-form-item label="成立日期" prop="f010d">
                      <el-input v-model="formData.f010d" placeholder="请输入成立日期" />
                    </el-form-item>
                    <el-form-item label="机构网址" prop="f011v">
                      <el-input v-model="formData.f011v" placeholder="请输入机构网址" />
                    </el-form-item>
                    <el-form-item label="电子信箱" prop="f012v">
                      <el-input v-model="formData.f012v" placeholder="请输入电子信箱" />
                    </el-form-item>
                    <el-form-item label="联系电话" prop="f013v">
                      <el-input v-model="formData.f013v" placeholder="请输入联系电话" />
                    </el-form-item>
                    <el-form-item label="联系传真" prop="f014v">
                      <el-input v-model="formData.f014v" placeholder="请输入联系传真" />
                    </el-form-item>
                    <el-form-item label="主营业务" prop="f015v">
                      <el-input v-model="formData.f015v" placeholder="请输入主营业务" />
                    </el-form-item>
                    <el-form-item label="经营范围" prop="f016v">
                      <el-input v-model="formData.f016v" placeholder="请输入经营范围" />
                    </el-form-item>
                    <el-form-item label="机构简介/公司成立概况" prop="f017v">
                      <el-input v-model="formData.f017v" placeholder="请输入机构简介/公司成立概况" />
                    </el-form-item>
                    <el-form-item label="董事会秘书" prop="f018v">
                      <el-input v-model="formData.f018v" placeholder="请输入董事会秘书" />
                    </el-form-item>
                    <el-form-item label="董秘联系电话" prop="f019v">
                      <el-input v-model="formData.f019v" placeholder="请输入董秘联系电话" />
                    </el-form-item>
                    <el-form-item label="董秘联系传真" prop="f020v">
                      <el-input v-model="formData.f020v" placeholder="请输入董秘联系传真" />
                    </el-form-item>
                    <el-form-item label="董秘电子邮箱" prop="f021v">
                      <el-input v-model="formData.f021v" placeholder="请输入董秘电子邮箱" />
                    </el-form-item>
                    <el-form-item label="证券事务代表" prop="f022v">
                      <el-input v-model="formData.f022v" placeholder="请输入证券事务代表" />
                    </el-form-item>
                    <el-form-item label="上市状态编码" prop="f023v">
                      <el-input v-model="formData.f023v" placeholder="请输入上市状态编码" />
                    </el-form-item>
                    <el-form-item label="上市状态" prop="f024v">
                      <el-input v-model="formData.f024v" placeholder="请输入上市状态" />
                    </el-form-item>
                    <el-form-item label="所属省份编码" prop="f025v">
                      <el-input v-model="formData.f025v" placeholder="请输入所属省份编码" />
                    </el-form-item>
                    <el-form-item label="所属省份" prop="f026v">
                      <el-input v-model="formData.f026v" placeholder="请输入所属省份" />
                    </el-form-item>
                    <el-form-item label="所属城市编码" prop="f027v">
                      <el-input v-model="formData.f027v" placeholder="请输入所属城市编码" />
                    </el-form-item>
                    <el-form-item label="所属城市" prop="f028v">
                      <el-input v-model="formData.f028v" placeholder="请输入所属城市" />
                    </el-form-item>
                    <el-form-item label="中上协一级行业编码" prop="f029v">
                      <el-input v-model="formData.f029v" placeholder="请输入中上协一级行业编码" />
                    </el-form-item>
                    <el-form-item label="中上协一级行业名称" prop="f030v">
                      <el-input v-model="formData.f030v" placeholder="请输入中上协一级行业名称" />
                    </el-form-item>
                    <el-form-item label="中上协二级行业编码" prop="f031v">
                      <el-input v-model="formData.f031v" placeholder="请输入中上协二级行业编码" />
                    </el-form-item>
                    <el-form-item label="中上协二级行业名称" prop="f032v">
                      <el-input v-model="formData.f032v" placeholder="请输入中上协二级行业名称" />
                    </el-form-item>
                    <el-form-item label="申万行业分类一级编码" prop="f033v">
                      <el-input v-model="formData.f033v" placeholder="请输入申万行业分类一级编码" />
                    </el-form-item>
                    <el-form-item label="申万行业分类一级名称" prop="f034v">
                      <el-input v-model="formData.f034v" placeholder="请输入申万行业分类一级名称" />
                    </el-form-item>
                    <el-form-item label="申万行业分类二级编码" prop="f035v">
                      <el-input v-model="formData.f035v" placeholder="请输入申万行业分类二级编码" />
                    </el-form-item>
                    <el-form-item label="申万行业分类二级名称" prop="f036v">
                      <el-input v-model="formData.f036v" placeholder="请输入申万行业分类二级名称" />
                    </el-form-item>
                    <el-form-item label="申万行业分类三级编码" prop="f037v">
                      <el-input v-model="formData.f037v" placeholder="请输入申万行业分类三级编码" />
                    </el-form-item>
                    <el-form-item label="申万行业分类三级名称" prop="f038v">
                      <el-input v-model="formData.f038v" placeholder="请输入申万行业分类三级名称" />
                    </el-form-item>
                    <el-form-item label="会计师事务所" prop="f039v">
                      <el-input v-model="formData.f039v" placeholder="请输入会计师事务所" />
                    </el-form-item>
                    <el-form-item label="律师事务所" prop="f040v">
                      <el-input v-model="formData.f040v" placeholder="请输入律师事务所" />
                    </el-form-item>
                    <el-form-item label="董事长" prop="f041v">
                      <el-input v-model="formData.f041v" placeholder="请输入董事长" />
                    </el-form-item>
                    <el-form-item label="总经理" prop="f042v">
                      <el-input v-model="formData.f042v" placeholder="请输入总经理" />
                    </el-form-item>
                    <el-form-item label="公司独立董事(现任)" prop="f043v">
                      <el-input v-model="formData.f043v" placeholder="请输入公司独立董事(现任)" />
                    </el-form-item>
                    <el-form-item label="入选指数" prop="f044v">
                      <el-input v-model="formData.f044v" placeholder="请输入入选指数" />
                    </el-form-item>
                    <el-form-item label="最新报告预约日期" prop="f045v">
                      <el-input v-model="formData.f045v" placeholder="请输入最新报告预约日期" />
                    </el-form-item>
                    <el-form-item label="保荐机构" prop="f046v">
                      <el-input v-model="formData.f046v" placeholder="请输入保荐机构" />
                    </el-form-item>
                    <el-form-item label="主承销商" prop="f047v">
                      <el-input v-model="formData.f047v" placeholder="请输入主承销商" />
                    </el-form-item>
                    <el-form-item label="PEVC标记" prop="f048v">
                      <el-input v-model="formData.f048v" placeholder="请输入PEVC标记" />
                    </el-form-item>
                    <el-form-item label="注册国家" prop="f049v">
                      <el-input v-model="formData.f049v" placeholder="请输入注册国家" />
                    </el-form-item>
                    <el-form-item label="统一社会信用代码" prop="f050v">
                      <el-input v-model="formData.f050v" placeholder="请输入统一社会信用代码" />
                    </el-form-item>
                    <el-form-item label="工商ID" prop="f051v">
                      <el-input v-model="formData.f051v" placeholder="请输入工商ID" />
                    </el-form-item>
                    <el-form-item label="可转债" prop="f052v">
                      <el-input v-model="formData.f052v" placeholder="请输入可转债" />
                    </el-form-item>
                    <el-form-item label="CDR" prop="f053v">
                      <el-input v-model="formData.f053v" placeholder="请输入CDR" />
                    </el-form-item>
                    <el-form-item label="企业规模" prop="f054v">
                      <el-input v-model="formData.f054v" placeholder="请输入企业规模" />
                    </el-form-item>
      </el-form>
              <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" :disabled="formLoading">确 定</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import * as GsBaseApi from '@/api/invest/gsbase';
      export default {
    name: "GsBaseForm",
    components: {
                    },
    data() {
      return {
        // 弹出层标题
        dialogTitle: "",
        // 是否显示弹出层
        dialogVisible: false,
        // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用
        formLoading: false,
        // 表单参数
        formData: {
                            orgid: undefined,
                            orgname: undefined,
                            seccode: undefined,
                            secname: undefined,
                            f001v: undefined,
                            f002v: undefined,
                            f003v: undefined,
                            f004v: undefined,
                            f005v: undefined,
                            f006v: undefined,
                            f007n: undefined,
                            f008v: undefined,
                            f009v: undefined,
                            f010d: undefined,
                            f011v: undefined,
                            f012v: undefined,
                            f013v: undefined,
                            f014v: undefined,
                            f015v: undefined,
                            f016v: undefined,
                            f017v: undefined,
                            f018v: undefined,
                            f019v: undefined,
                            f020v: undefined,
                            f021v: undefined,
                            f022v: undefined,
                            f023v: undefined,
                            f024v: undefined,
                            f025v: undefined,
                            f026v: undefined,
                            f027v: undefined,
                            f028v: undefined,
                            f029v: undefined,
                            f030v: undefined,
                            f031v: undefined,
                            f032v: undefined,
                            f033v: undefined,
                            f034v: undefined,
                            f035v: undefined,
                            f036v: undefined,
                            f037v: undefined,
                            f038v: undefined,
                            f039v: undefined,
                            f040v: undefined,
                            f041v: undefined,
                            f042v: undefined,
                            f043v: undefined,
                            f044v: undefined,
                            f045v: undefined,
                            f046v: undefined,
                            f047v: undefined,
                            f048v: undefined,
                            f049v: undefined,
                            f050v: undefined,
                            f051v: undefined,
                            f052v: undefined,
                            f053v: undefined,
                            f054v: undefined,
        },
        // 表单校验
        formRules: {
        },
                        };
    },
    methods: {
      /** 打开弹窗 */
     async open(id) {
        this.dialogVisible = true;
        this.reset();
        // 修改时，设置数据
        if (id) {
          this.formLoading = true;
          try {
            const res = await GsBaseApi.getGsBase(id);
            this.formData = res.data;
            this.title = "修改公司基本信息";
          } finally {
            this.formLoading = false;
          }
        }
        this.title = "新增公司基本信息";
              },
      /** 提交按钮 */
      async submitForm() {
        // 校验主表
        await this.$refs["formRef"].validate();
                  this.formLoading = true;
        try {
          const data = this.formData;
                  // 修改的提交
          if (data.seccode) {
            await GsBaseApi.updateGsBase(data);
            this.$modal.msgSuccess("修改成功");
            this.dialogVisible = false;
            this.$emit('success');
            return;
          }
          // 添加的提交
          await GsBaseApi.createGsBase(data);
          this.$modal.msgSuccess("新增成功");
          this.dialogVisible = false;
          this.$emit('success');
        } finally {
          this.formLoading = false;
        }
      },
                      /** 表单重置 */
      reset() {
        this.formData = {
                            orgid: undefined,
                            orgname: undefined,
                            seccode: undefined,
                            secname: undefined,
                            f001v: undefined,
                            f002v: undefined,
                            f003v: undefined,
                            f004v: undefined,
                            f005v: undefined,
                            f006v: undefined,
                            f007n: undefined,
                            f008v: undefined,
                            f009v: undefined,
                            f010d: undefined,
                            f011v: undefined,
                            f012v: undefined,
                            f013v: undefined,
                            f014v: undefined,
                            f015v: undefined,
                            f016v: undefined,
                            f017v: undefined,
                            f018v: undefined,
                            f019v: undefined,
                            f020v: undefined,
                            f021v: undefined,
                            f022v: undefined,
                            f023v: undefined,
                            f024v: undefined,
                            f025v: undefined,
                            f026v: undefined,
                            f027v: undefined,
                            f028v: undefined,
                            f029v: undefined,
                            f030v: undefined,
                            f031v: undefined,
                            f032v: undefined,
                            f033v: undefined,
                            f034v: undefined,
                            f035v: undefined,
                            f036v: undefined,
                            f037v: undefined,
                            f038v: undefined,
                            f039v: undefined,
                            f040v: undefined,
                            f041v: undefined,
                            f042v: undefined,
                            f043v: undefined,
                            f044v: undefined,
                            f045v: undefined,
                            f046v: undefined,
                            f047v: undefined,
                            f048v: undefined,
                            f049v: undefined,
                            f050v: undefined,
                            f051v: undefined,
                            f052v: undefined,
                            f053v: undefined,
                            f054v: undefined,
        };
        this.resetForm("formRef");
      }
    }
  };
</script>
